#include <iostream>
#include "fservice.h"
const char* NAME ="TEST";
#define FDB_CONTEXT CFdbContext::getInstance()
static CBaseWorker main_worker;
int main() {
#ifdef __WIN32__
    WORD wVersionRequested;
    WSADATA wsaData;
    int err;

/* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
    wVersionRequested = MAKEWORD(2, 2);

    err = WSAStartup(wVersionRequested, &wsaData);
    if (err != 0) {
        /* Tell the user that we could not find a usable */
        /* Winsock DLL.                                  */
        printf("WSAStartup failed with error: %d\n", err);
        return 1;
    }
#endif
    printf("Hello, World!\n");
    /* start fdbus context thread */
    FDB_CONTEXT->start();
    CBaseWorker *worker_ptr = &main_worker;
    /* start worker thread */
    worker_ptr->start();

    std::string server_name = NAME;
    std::string url(FDB_URL_SVC);
    url += server_name;
    server_name += "_server";
    auto server = new FService(server_name.c_str(), worker_ptr);
    server->bind(url.c_str());


    /* convert main thread into worker */
    CBaseWorker background_worker;
    background_worker.start(FDB_WORKER_EXE_IN_PLACE);
}
